package com.hiof.location;

import com.hiof.servercommunication.receive.beans.GeoPoint;

import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 * User: manish
 * Date: 4/17/12
 * Time: 6:44 PM
 * To change this template use File | Settings | File Templates.
 */
public abstract class GPSManager {
    public ArrayList<LocationChangedListener> listeners = new ArrayList<LocationChangedListener>();
    public abstract GeoPoint getLatestLocation();
    public abstract double getLatestSpeed();
    public abstract void destroy();

    public void registerListener(LocationChangedListener listener){
        listeners.add(listener);
    }

    public void removeListener(LocationChangedListener listener){
        listeners.remove(listener);
    }

    protected void fireEvent(GeoPoint geoPoint){
        for(LocationChangedListener listener : listeners){
            listener.updateLocationChanged(geoPoint);
        }
    }
}
